//4
let axios = require('axios');
let fs = require('fs');
let path = require('path');
let arr = ['你好', '爱你', '美好', '约会', '未来可期', '前端', '拉平', '垂直领域', '面向对象', '联调', '禅道', '流式布局', '组合拳', '生态链', '痛点', '无痛', '生命周期', '上层应用', '柯里化', '隐式原型', '上下文', 'BFC', '给与组合式的打击,平衡用户的痛点'];

let promiseArr = [];

arr.forEach(item => promiseArr.push(translate(item)));

function translate(word) {
  return new Promise((resolve) => {
    axios({
      method: 'GET',
      params: {q: word},
      url: 'https://gitee.com/search/translate'
    }).then(res => {
      let {data} = res;
      resolve(data.result)
    }).catch(err => {
      resolve(undefined);
    })
  })
}


Promise.all(promiseArr).then(res => {
  console.log(res);
  res.filter(item => item && fs.mkdirSync(path.join(__dirname, 'child', item)));
});


setTimeout(() => {

}, 100000000);
